workspace "Origin"
	configurations { "Debug", "Release" }
	architecture "x64" --x86_64是x64的别名

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"

startproject "SandBox"

include "Origin/Vendor/configs/glfw.lua" 
include "Origin/Vendor/configs/glad.lua"
include "Origin/Vendor/configs/imgui.lua"

project "Origin"
	location "Origin"	--使用 location 可以将生成的项目文件放在一个专门的目录中
	kind "StaticLib"	--A shared library or DLL
	language "C++"
	cppdialect "C++17"
	--on:  Sets RuntimeLibrary to "MultiThreaded"
	--off: Sets RuntimeLibrary to "MultiThreadedDLL"
	--staticlib with /MT means that the exe file linking to this lib has its individual storage
	staticruntime "on"  


	--compilied output
	targetdir ("bin/" .. outputdir .. "/%{prj.name}")

	--where intermediate files should be placed
	objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

	pchheader "OriginPCH.h"
	pchsource "%{prj.name}/Src/OriginPCH.cpp"

	files 
	{ 
		"%{prj.name}/Src/**.h",
		"%{prj.name}/Src/**.cpp",
		"%{prj.name}/Vendor/glm/glm/**.hpp",
		"%{prj.name}/Vendor/glm/glm/**.inl"
	} --Adds files to a project.

	defines
	{
		"_CRT_SECURE_NO_WARNINGS"
	}

	includedirs
	{
		"%{prj.name}/Vendor/spdlog/include",
		"%{prj.name}/Vendor/glfw/include",
		"%{prj.name}/Vendor/glad/include",
		"%{prj.name}/Vendor/imgui",
		"%{prj.name}/Vendor/glm",
		"%{prj.name}/Vendor/stb_image",
		"%{prj.name}/Src",
		"%{prj.name}/Src/Platform"
	}

	links
	{
		"GLFW",
		"GLAD",
		"ImGui",
		"opengl32.lib"
	}

	filter "system:Windows"
		systemversion "latest"

		defines
		{
			"ORIGIN_PLATFORM_WINDOWS",
			"ORIGIN_SOURCE"
		}

		postbuildcommands
		{
			--command tokens
			("{COPYFILE} %[bin/"..outputdir.."/Origin/Origin.lib] %[bin/"..outputdir.."/SandBox/Origin.lib]") 
			--("{COPY} %{cfg.buildtarget.relpath} ../bin/" .. outputdir .. "/SandBox/Origin.dll")
		}

	filter "configurations:Debug"
		defines "ORIGIN_DEBUG"
		runtime "Debug"
		symbols "on"

	filter "configurations:Release"
		defines "ORIGIN_RELEASE"
		runtime "Release"
		symbols "on"

project "SandBox"
	location "SandBox"  --使用 location 可以将生成的项目文件放在一个专门的目录中
	kind "ConsoleApp"   --A shared library or DLL
	language "C++"
	cppdialect "C++17"
	staticruntime "on"  --是否将C++库，静态链接到生成的二进制文件中

	--compilied output
	targetdir ("bin/" .. outputdir .. "/%{prj.name}")

	--where intermediate files should be placed
	objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

	files 
	{ 
		"%{prj.name}/Src/**.h",
		"%{prj.name}/Src/**.cpp"
	} --Adds files to a project.

	includedirs
	{
		"Origin/Vendor/spdlog/include",
		"Origin/Vendor/glfw/include",
		"Origin/Vendor/glad/include",
		"Origin/Vendor/imgui",
		"Origin/Vendor/glm",
		"Origin/Vendor/stb_image",
		"Origin/Src",
		"Origin/Src/Platform"
	}

	links
	{
		"Origin"
	}

	filter "system:windows"
		cppdialect "C++17"
		systemversion "latest"

		defines
		{
			"ORIGIN_PLATFORM_WINDOWS",
		}

	filter "configurations:Debug"
		defines "ORIGIN_DEBUG"
		runtime "Debug"
		symbols "on"

	filter "configurations:Release"
		defines "ORIGIN_RELEASE"
		runtime "Release"
		symbols "on"